package com.sec.etech.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;

@Component
public class BpmFormActionMap {

    @Data
    @AllArgsConstructor
    public static class OpposeAction{
        String businessKey;
        String businessId;
        Consumer<String> action;
    }

    public static final Map<String, List<String>> AGREE_MAP = new ConcurrentHashMap<>();
    public static final Map<String, OpposeAction> OPPOSE_MAP =  new ConcurrentHashMap<>();

    public void registerAgreeAction(String key, List<String> aopAction){
        AGREE_MAP.put(key, aopAction);
    }

    public List<String> getAgreeAction(String key){
        return AGREE_MAP.getOrDefault(key, null);
    }

    public void registerOpposeAction(String key, OpposeAction action){
        OPPOSE_MAP.put(key, action);
    }

    public OpposeAction getOpposeAction(String key){
        return OPPOSE_MAP.getOrDefault(key, null);
    }

}
